const { compareSync } = require('bcryptjs');
var express = require('express');
var router = express.Router();
var followModel = require("../database/model/followModel")
    /* GET users listing. */
router.post('/follow', function(req, res, next) {
    console.log(req.body)
    let { username, avatar, name, jobTitle, albumNum } = req.body
    new followModel({ username, avatar, name, jobTitle, albumNum }).save().then(result => {
        res.send({
            code: 1,
            msg: "添加成功"
        })
    })
})

router.delete('/follow', function(req, res, next) {
    console.log(req.query)
    followModel.remove(req.query).then(result => {
        console.log(result);
        res.send({
            code: 1,
            msg: "取消成功"
        })
    })
})


router.get('/follow', function(req, res, next) {
    console.log(req.query)
    followModel.find(req.query).then(result => {
        console.log(result);
        res.send({
            code: 1,
            msg: "获取关注成功",
            result
        })
    })
})
module.exports = router;